home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 September / EnigmA AMIGA RUN 10 (1996)(G.R. Edizioni)(IT)[!][issue 1996-09][EARSAN CD XI].iso / internet / others / cloneclock.lha / cloneclock.s < prev   
Text File  |  1995-07-28  |  3KB  |  163 lines

  1. *************************************************************
  2. ** SLICER's CloneClock
  3. *************************************************************
  4.  
  5.     execbase=4
  6.  
  7.     OpenLib=-408        ;DOS
  8.     CloseLib=-414
  9.     Output=-60
  10.     Write=-48
  11.     DateStamp=-192
  12.     DateToStr=-744
  13.     Execute=-222
  14.     Delay=-198
  15.  
  16. ;--------- MAIN
  17.  
  18. start:        move.l    a0,argpointer    ;we'll need it!!
  19.         bsr.w    opendos
  20.         beq.b    .panic
  21.         bsr.b    writeshit
  22.         bsr.b    validatearg
  23.         bcs.b    .stupid        ;you didn't read the docs
  24.         bsr.b    getstamp    ;get time and generate structure
  25.         beq.b    .close
  26.         bsr.w    cpydateandtime
  27.         bsr.w    transferclock
  28.         bsr.b    waiter
  29.         bsr.w    saveclock
  30. .close        bsr.w    closeDOS
  31. .panic:        rts
  32.  
  33. .stupid:    move.l    #param,d2        ;write stuff
  34.         move.l    #paramend-param,d3
  35.         bsr.b    writeit
  36.         bsr.b    .close
  37.         rts
  38.  
  39. ;--------- USEFUL CODE
  40.  
  41. writeshit:    move.l    dosbase(pc),a6
  42.         move.l    #comment,d2
  43.         move.l    #commentend-comment,d3
  44.         bsr.b    writeit
  45.         rts
  46.  
  47. writeit:    JSR    -60(A6)
  48.         MOVE.L    D0,D1
  49.         JSR    -48(A6)                ;Ud med tekst
  50.         rts
  51.  
  52. getstamp:    move.l    #clockdata,d1
  53.         jsr    datestamp(a6)
  54.         jsr    DateToStr(a6)
  55.         tst.l    d0
  56.         rts
  57.  
  58. validatearg:    move.l    argpointer(pc),a0
  59.         moveq    #0,d1
  60.         move.b    (a0),d1
  61.         cmp2.b    .range,d1    ;use this instruction if you have 020++
  62.         bcs.b    .end
  63.  
  64. ;        cmp.b    .range,d1    ;else use these..
  65. ;        bcs.b    .end
  66. ;        cmp.b    .range+1,d1
  67. ;        bhi.b    .end
  68.  
  69.         andi.b    #$0f,d1        ;mask out unwanted bits
  70.         move.b    d1,argbyte
  71.         rts
  72. .end:        ori.b    #1,ccr        ;set carry
  73.         rts
  74. .range:    dc.b    $30,$39
  75.  
  76.  
  77. waiter:        move.b    argbyte(pc),d1
  78.         mulu.w    #50,d1        ;1 second = 50 tics
  79.         jsr    delay(a6)
  80.         rts
  81.  
  82. cpydateandtime:    lea    thedate(pc),a0
  83.         lea    date(pc),a1
  84.         moveq    #8,d0
  85. .again:        move.b    (a0)+,(a1)+    ;copy the date in place
  86.         dbra    d0,.again
  87.         lea    thetime(pc),a0
  88.         lea    time(pc),a1
  89.         moveq    #7,d0
  90. .again2:    move.b    (a0)+,(a1)+    ;copy the time to its rightfull place
  91.         dbra    d0,.again2
  92.         rts
  93.  
  94. transferclock:    move.l    #netcmd,d1    ;command addr.
  95.         bsr.b    shootshit
  96.         rts
  97.  
  98. saveclock:    move.l    #netcmd2,d1    ;2nd command addr.
  99.         bsr.b    shootshit
  100.         rts
  101.  
  102. shootshit:    moveq    #0,d2
  103.         moveq    #0,d3
  104.         jsr    Execute(a6)    ;do it!
  105.         tst.l    d0        ;success?
  106.         rts
  107.  
  108. ;--------- SYSTEM ROUTINES
  109.  
  110. opendos:    move.l    (execbase).w,a6
  111.         lea    dosname(pc),a1
  112.         jsr    OpenLib(a6)
  113.         move.l    d0,dosbase
  114.         rts
  115.  
  116. closedos:    move.l    dosbase(pc),a1
  117.         move.l  (execbase).w,a6 
  118.         jsr     CloseLib(a6)
  119.         rts
  120.  
  121. ;---------- DATA STUFF
  122.  
  123. dosname:    dc.b    'dos.library',0
  124. dosbase:    dc.l    0
  125. argpointer:    dc.l    0
  126. argbyte:    dc.b    0
  127.  
  128.         even
  129. ClockData:    dc.w    0    ;UWORD sec
  130.         dc.w    0    ;UWORD min
  131.         dc.w    0    ;UWORD hour
  132.         dc.w    0    ;UWORD mday
  133.         dc.w    0    ;UWORD month
  134.         dc.w    0    ;UWORD year
  135.  
  136.         dc.b    0    ;dat_Format (dos setting)
  137.         dc.b    0    ;dat_Flags (no today/tomorrow etc.)
  138.         dc.l    0    ;dat_StrDay -and we need no pointer to that
  139.         dc.l    thedate    ;dat_StrDate
  140.         dc.l    thetime    ;dat_StrTime
  141.  
  142. thedate:    blk.b    16,0
  143. thetime:    blk.b    16,0
  144.  
  145. netcmd:    dc.b    'netcmd "date '
  146. date:    blk.b    9,0
  147.     dc.b    ' '
  148. time:    blk.b    8,0    
  149.     dc.b    '"',0
  150. netcmd2: dc.b    'netcmd "setclock save"',0
  151.  
  152. comment:    dc.b    $9b,"1;3;4;33;40m"
  153.         dc.b    'CloneClock by SLICER -1995'
  154.         dc.b    $9b,"0;31;40m"
  155.         dc.b    13,10
  156. commentend:
  157. ver:    dc.b    '$VER: CloneClock v0.99997',0
  158.  
  159. param:    dc.b    'Cloneclock d',10,13
  160.     dc.b    'where d (delay in seconds) is [0-9]',10,13
  161. paramend:
  162.  
  163.